﻿@*YoursLC有源低代码 Create:φ创建者Creatorφ 2022-05-07 19:30:26 弹出选择-此文件放置于Views/Demo01VariousControls/中*@

@using Think9.Models;
@{ ViewBag.Title = "Index";
	Layout = "~/Areas/Shared/_LayuiForm.cshtml"; }

<input style="display:none" id="sys_flag" value="inTextBoxPopup1">
<input style="display:none" id="Pu_from" value="@ViewBag.PuFrom">
<input style="display:none" id="Pu_tbid" value="@ViewBag.PuTbId">
<input style="display:none" id="Pu_indexid" value="@ViewBag.PuIndexId">
<input style="display:none" id="Pu_id" value="@ViewBag.PuId">
<input style="display:none" id="Pu_v" value="@ViewBag.PuV">
<fieldset class="table-fieldset" id="searchfield" style="display:none">
	<legend>快速查询</legend>
	<div style="margin: 5px 5px 5px 5px">
		<form class="layui-form layui-form-pane" action="">
			<div class="layui-row layui-col-space15">
				<div class="layui-col-md6">
					<label class="layui-form-label">员工编码</label>
					<div class="layui-input-block">
						<input type='text' name="inEmployeeCode" id="inEmployeeCode" autocomplete='off' class='layui-input'>
					</div>
				</div>
				<div class="layui-col-md6">
					<label class="layui-form-label">员工姓名</label>
					<div class="layui-input-block">
						<input type='text' name="inEmployeeName" id="inEmployeeName" autocomplete='off' class='layui-input'>
					</div>
				</div>
			 </div>
			<div class="layui-row layui-col-space15">
				<div class="layui-col-md6">
					<label class="layui-form-label">员工部门</label>
					<div class="layui-input-block">
						<select id="inEmployeeDepartment" name="inEmployeeDepartment">
							<option value="">==请选择==</option>
								@foreach (valueTextEntity item in ((IEnumerable<valueTextEntity>)ViewBag.SelectList).Where(x => x.ClassID == "inEmployeeDepartment"))
								{
									 <option value="@item.Value">@item.Text</option>
								}
						</select>
					</div>
				</div>
				<div class="layui-col-md6">
					<label class="layui-form-label">员工岗位</label>
					<div class="layui-input-block">
						<select id="inEmployeePosition" name="inEmployeePosition">
							<option value="">==请选择==</option>
								@foreach (valueTextEntity item in ((IEnumerable<valueTextEntity>)ViewBag.SelectList).Where(x => x.ClassID == "inEmployeePosition"))
								{
									 <option value="@item.Value">@item.Text</option>
								}
						</select>
					</div>
				</div>
			 </div>
			<div class="layui-row layui-col-space15">
				<div class="layui-col-md6">
					<label class="layui-form-label">入职日期</label>
					<div class="layui-input-inline">
						<div class="layui-input-inline" style="width: 160px; ">
							<input  name="inEntryDate" id="inEntryDate" autocomplete='off' class='layui-input'  onClick="WdatePicker({ el: this,dateFmt: 'yyyy-MM-dd'})">
						</div>
						<div class="layui-input-inline" style="width: 5px; ">-</div>
						<div class="layui-input-inline" style="width: 160px; ">
							<input  name="inEntryDate_Exa" id="inEntryDate_Exa" autocomplete='off' class='layui-input'  onClick="WdatePicker({ el: this,dateFmt: 'yyyy-MM-dd'})">
						</div>
					</div>
				</div>
				<div class="layui-col-md6">
					<label class="layui-form-label">基本工资</label>
					<div class="layui-input-inline">
						<div class="layui-input-inline" style="width: 160px; ">
							<input type='text' name="inBasePay" id="inBasePay" autocomplete='off' class='layui-input'  lay-verify='number' >
						</div>
						<div class="layui-input-inline" style="width: 5px; ">-</div>
						<div class="layui-input-inline" style="width: 160px; ">
							<input type='text' name="inBasePay_Exa" id="inBasePay_Exa" autocomplete='off' class='layui-input'  lay-verify='number' >
						</div>
					</div>
				</div>
			 </div>
			<div class="layui-row layui-col-space15">
				<div class="layui-col-md6">
					<label class="layui-form-label">绩效工资</label>
					<div class="layui-input-inline">
						<div class="layui-input-inline" style="width: 160px; ">
							<input type='text' name="inMeritPay" id="inMeritPay" autocomplete='off' class='layui-input'  lay-verify='number' >
						</div>
						<div class="layui-input-inline" style="width: 5px; ">-</div>
						<div class="layui-input-inline" style="width: 160px; ">
							<input type='text' name="inMeritPay_Exa" id="inMeritPay_Exa" autocomplete='off' class='layui-input'  lay-verify='number' >
						</div>
					</div>
				</div>
				<div class="layui-col-md6">
					<label class="layui-form-label">岗位工资</label>
					<div class="layui-input-inline">
						<div class="layui-input-inline" style="width: 160px; ">
							<input type='text' name="inPostSalary" id="inPostSalary" autocomplete='off' class='layui-input'  lay-verify='number' >
						</div>
						<div class="layui-input-inline" style="width: 5px; ">-</div>
						<div class="layui-input-inline" style="width: 160px; ">
							<input type='text' name="inPostSalary_Exa" id="inPostSalary_Exa" autocomplete='off' class='layui-input'  lay-verify='number' >
						</div>
					</div>
				</div>
			 </div>
			<div class="layui-row layui-col-space15">
				<div class="layui-col-md6">
					<label class="layui-form-label">职称津贴</label>
					<div class="layui-input-inline">
						<div class="layui-input-inline" style="width: 160px; ">
							<input type='text' name="inTitleAllowance" id="inTitleAllowance" autocomplete='off' class='layui-input'  lay-verify='number' >
						</div>
						<div class="layui-input-inline" style="width: 5px; ">-</div>
						<div class="layui-input-inline" style="width: 160px; ">
							<input type='text' name="inTitleAllowance_Exa" id="inTitleAllowance_Exa" autocomplete='off' class='layui-input'  lay-verify='number' >
						</div>
					</div>
				</div>
				<div class="layui-col-md6">
					<label class="layui-form-label">调薪时间</label>
					<div class="layui-input-inline">
						<div class="layui-input-inline" style="width: 160px; ">
							<input  name="inSalaryAdjustmentTime" id="inSalaryAdjustmentTime" autocomplete='off' class='layui-input'  onClick="WdatePicker({ el: this,dateFmt: 'yyyy-MM-dd'})">
						</div>
						<div class="layui-input-inline" style="width: 5px; ">-</div>
						<div class="layui-input-inline" style="width: 160px; ">
							<input  name="inSalaryAdjustmentTime_Exa" id="inSalaryAdjustmentTime_Exa" autocomplete='off' class='layui-input'  onClick="WdatePicker({ el: this,dateFmt: 'yyyy-MM-dd'})">
						</div>
					</div>
				</div>
			 </div>
			<div class="layui-row layui-col-space15">
				<div class="layui-col-md6">
					<button type='button' class='layui-btn layui-btn-normal' id='search' lay-submit lay-filter='search'><i class='layui-icon layui-icon-search'></i></button> <button type='reset' class='layui-btn layui-btn-primary'><i class='layui-icon layui-icon-refresh'></i></button>
				</div>
			 </div>
		</form>
	</div>
</fieldset>

<table class="layui-hide" id="tableId" lay-filter="tableFilter"></table>

<script>
	layui.config({
		base: '/self_js/' /*自定义的js文件 位于wwwroot/self_js文件夹中*/
	});
	layui.use(["table", "form", "exLayer", "exUtils", "Demo01VariousControls"], function () {
		let table = layui.table;
		let form = layui.form;
		let exLayer = layui.exLayer;
		let exUtils = layui.exUtils;
		let mySelf = layui.Demo01VariousControls;

		let $ = layui.$;

		form.render(); //初始化表单，要加上，不然刷新部分组件可能会不加载

		let ThisTable = table.render({
			elem: "#tableId",
			url: "/Demo01VariousControls/GetPopUpTablePageList?indexid=" + $('#sys_flag').val() + "&from=" + $('#Pu_from').val(),
			limits: [10, 50, 100],
			limit: 10,
			method:"POST",
			page: true,
			defaultToolbar: [{ title: '搜索', layEvent: 'searchShow', icon: 'layui-icon-search' }, 'filter', 'exports'],
			toolbar: "#toolbarTpl",
			cols: [[
			{ type: "checkbox" }

			   ,{ type: "numbers", title: ".NO" }
			   ,{ field: "Value", hide: true  }
				,{ field: "info1", title: "员工编码" }
				,{ field: "info2", title: "员工姓名" }
				,{ field: "info3", title: "员工部门" }
				,{ field: "info4", title: "员工岗位" }
				,{ field: "info5", title: "入职日期" }
				,{ field: "info6", title: "基本工资" }
				,{ field: "info7", title: "绩效工资" }
				,{ field: "info8", title: "岗位工资" }
			]],
			done: function (res, curr, count) {
			}
		});

		 //查询
		form.on("submit(search)", function (data) {
			$("#searchfield").hide();
			var _list = [];
			getControlSearch(_list);
			console.log(_list);

			ThisTable.reload({
				where: { flag: $('#sys_flag').val(), "list": _list },
				page: { curr: 1 }
			});
			return false;
		});

		table.on("toolbar(tableFilter)", function (obj) {
			switch (obj.event) {
				case "OK":
					getPopUpSelect(obj);
					break;
				case "searchShow":
					mySelf.searchShow();
					break;
			}
		});

		function getPopUpSelect(obj) {
			var strv = '';
			var checkStatus = table.checkStatus("tableId");
			var rows = checkStatus.data.length;
			if (rows > 0) {
				for (var i = 0; i < checkStatus.data.length; i++) {
					strv += checkStatus.data[i].Value + " ";
				}
			}

            //为父页面控件赋值
			$(window.parent.document).find('#Pu_value').val(strv);//选择的值
			$(window.parent.document).find('#Pu_tbid').val($('#Pu_tbid').val());//表id
			$(window.parent.document).find('#Pu_indexid').val($('#Pu_indexid').val());//指标编码
			$(window.parent.document).find('#Pu_id').val($('#Pu_id').val());//子表弹出时使用 对应table中id 行
			$(window.parent.document).find('#Pu_v').val($('#Pu_v').val());//子表弹出时使用 第几列

			$(window.parent.document).find('#Pu_value').click();//调用父页面事件 完成控件赋值及数据读取

			parent.layer.close(parent.layer.getFrameIndex(window.name));
		}

		//从控件读值
		function getControlSearch(_list) {
			//员工编码
			_list.push({ ClassID: $('#sys_flag').val(), Text:$('#inEmployeeCode').val(), Value:'inEmployeeCode'});
			//员工姓名
			_list.push({ ClassID: $('#sys_flag').val(), Text:$('#inEmployeeName').val(), Value:'inEmployeeName'});
			//员工部门
			_list.push({ ClassID: $('#sys_flag').val(), Text:$('#inEmployeeDepartment').val(), Value:'inEmployeeDepartment'});
			//员工岗位
			_list.push({ ClassID: $('#sys_flag').val(), Text:$('#inEmployeePosition').val(), Value:'inEmployeePosition'});
			//入职日期
			_list.push({ ClassID: $('#sys_flag').val(), Text:$('#inEntryDate').val(), Value:'inEntryDate'});
			_list.push({ ClassID: $('#sys_flag').val(), Text:$('#inEntryDate_Exa').val(), Value:'inEntryDate_Exa'});
			//基本工资
			_list.push({ ClassID: $('#sys_flag').val(), Text:$('#inBasePay').val(), Value:'inBasePay'});
			_list.push({ ClassID: $('#sys_flag').val(), Text:$('#inBasePay_Exa').val(), Value:'inBasePay_Exa'});
			//绩效工资
			_list.push({ ClassID: $('#sys_flag').val(), Text:$('#inMeritPay').val(), Value:'inMeritPay'});
			_list.push({ ClassID: $('#sys_flag').val(), Text:$('#inMeritPay_Exa').val(), Value:'inMeritPay_Exa'});
			//岗位工资
			_list.push({ ClassID: $('#sys_flag').val(), Text:$('#inPostSalary').val(), Value:'inPostSalary'});
			_list.push({ ClassID: $('#sys_flag').val(), Text:$('#inPostSalary_Exa').val(), Value:'inPostSalary_Exa'});
			//职称津贴
			_list.push({ ClassID: $('#sys_flag').val(), Text:$('#inTitleAllowance').val(), Value:'inTitleAllowance'});
			_list.push({ ClassID: $('#sys_flag').val(), Text:$('#inTitleAllowance_Exa').val(), Value:'inTitleAllowance_Exa'});
			//调薪时间
			_list.push({ ClassID: $('#sys_flag').val(), Text:$('#inSalaryAdjustmentTime').val(), Value:'inSalaryAdjustmentTime'});
			_list.push({ ClassID: $('#sys_flag').val(), Text:$('#inSalaryAdjustmentTime_Exa').val(), Value:'inSalaryAdjustmentTime_Exa'});
		}

	});
</script>
<!-- 头工具栏模板 -->
<script type="text/html" id="toolbarTpl">
	<button class="layui-btn layui-btn-normal layui-btn-sm" lay-event="OK" id="OK">确定选择</button>
</script>